import logging
from datetime import timedelta
import os


class BaseConfig:
    # 超级管理员账号
    SUPERADMIN = "admin"

    # 系统名称
    SYSTEM_NAME = "试验变压器管理系统"

    # 上传图片目标文件夹
    UPLOADED_PHOTOS_DEST = "static/upload"
    UPLOADED_FILES_ALLOW = ["gif", "jpg", "jpeg", "png", "webp"]
    UPLOADS_AUTOSERVE = True

    # JSON 配置
    JSON_AS_ASCII = False

    # 数据库的配置信息
    SQLALCHEMY_DATABASE_URI = "sqlite:///../detection.db"

    # 默认日志等级
    LOG_LEVEL = logging.WARN

    # 插件配置，填写插件的文件名名称，默认不启用插件。
    PLUGIN_ENABLE_FOLDERS = []

    # Session 设置
    PERMANENT_SESSION_LIFETIME = timedelta(days=7)

    SESSION_TYPE = "filesystem"  # 默认使用文件系统来保存会话
    SESSION_PERMANENT = False  # 会话是否持久化
    SESSION_USE_SIGNER = True  # 是否对发送到浏览器上 session 的 cookie 值进行加密

    SECRET_KEY = "detection-system"

    # 服务器配置
    HOST = os.environ.get("HOST", "127.0.0.1")
    PORT = int(os.environ.get("PORT", 5000))
    DEBUG = os.environ.get("DEBUG", "False").lower() == "true"
